import flash.events.EventDispatcher;
import flash.events.Event;
import haxe.FastList;



class CharacterStat extends EventDispatcher{
//Need Validation on get/setters
   private var _fear : Float;
   private var _suspicion: Float;

   public var MaxFear : Float;
   public var MaxSuspicion : Float;
   public var Money : Float;
   public var PrincessTotal:Int;
   public var PrincessUsed:Int;
   public var VillianUsed:Int;
   public var VillianTotal:Int;
   public var WriterTotal:Int;
   public var ResearcherTotal:Int;
   public var HeroTotal:Int;
   public var HeroUsed:Int;
   public var PopulationLevel:Int;
   public var Propaganda:Int;
   public var HostedEvents : Int;
  
   public var KidnapTime:Int;
   public var Kidnapings:KidnapList;
   public function new(){
	  PopulationLevel = 0;
	  _suspicion = 0;
	  MaxSuspicion = 10000;
	  _fear = 0;
	  MaxFear = 10000;
	  Money = 0;
	  PrincessUsed = 0;
	  PrincessTotal = 1;
	  VillianUsed = 0;
	  VillianTotal = 1;
	  HeroUsed = 0;
	  HeroTotal = 1;
	  WriterTotal = 0;
	  ResearcherTotal = 0;
	  KidnapTime = 100;
	  Propaganda = 0;
	  Kidnapings = new KidnapList();
          super();
    }
  //Get Costs
  public function getWriterCost():Int
  {
    return Math.floor((1000 * Math.pow(1.8,WriterTotal))/(ResearcherTotal+1));
  }

  public function getResearcherCost():Int
  {
    return Math.floor(5000 +((1000 * Math.pow(2.2,ResearcherTotal))/(ResearcherTotal+1)));
  }

  public function getTeamCost():Int
  {
    return Math.floor(((PrincessTotal)*10)/(ResearcherTotal+1));
  }

  public function getPropagandaCost():Int
  {
    return Math.floor((1000 * Math.pow(1.5,Propaganda))/(ResearcherTotal+1));
  }

  public function getExpandCastleCost():Int
  {
    return Math.floor(5000 * Math.pow(2,PopulationLevel));
  }
  public function getHostEventCost():Int
  {
    return Math.floor((1000 * Math.pow(1.6,HostedEvents))/(ResearcherTotal+1));
  }
  public function getSuspicionPerTurn():Float
  {
    var added = Math.pow(2,PopulationLevel)*0.25;
    if(PopulationLevel >= 3)
    added = PopulationLevel -1;
    return (added -(0.1*Propaganda));
  }
  public function getTeamLimit():Int
  {
    return 50*(PopulationLevel+1);
  }

  //Getter/Setters
  public var Fear(getFear,setFear):Float;
  public function getFear():Float
  {
    return _fear;
  }
  public function setFear(inFear:Float):Float
  {
    _fear = inFear;
    _fear = Math.min(MaxFear,_fear);
    _fear = Math.max(0,_fear);
    return _fear;
  }
  public var Suspicion(getSuspicion,setSuspicion) : Float;
  public function getSuspicion():Float
  {
    return _suspicion;
  }
  public function setSuspicion(inSuspicion:Float):Float
  {
    _suspicion = inSuspicion;
    _suspicion = Math.min(MaxSuspicion,_suspicion);
    _suspicion = Math.max(0,_suspicion);
    return _suspicion;
  }
   public function update()
   {
    dispatchEvent(new Event("updateValues",true,false));
   }
   
}